﻿

namespace System.Extensions.Compact
{
  using System;
  using System.Runtime.InteropServices;

  /// <summary>
  /// Provides methods for turning the display on and off on a smart client.
  /// </summary>
  public static class Video
  {
    /// <summary>
    /// Turn the display off.
    /// </summary>
    public static void PowerOff()
    {
      IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
      byte[] vpm = new byte[] { 12, 0, 0, 0, 1, 0, 0, 0, (byte)NativeMethods.VideoPowerState.VideoPowerOff, 0, 0, 0, 0 };
      NativeMethods.ExtEscape(hDc, NativeMethods.SETPOWERMANAGEMENT, 12, vpm, 0, IntPtr.Zero);
      NativeMethods.ReleaseDC(IntPtr.Zero, hDc);
    }

    /// <summary>
    /// Turn the display on.
    /// </summary>
    public static void PowerOn()
    {
      IntPtr hDc = NativeMethods.GetDC(IntPtr.Zero);
      byte[] vpm = new byte[] { 12, 0, 0, 0, 1, 0, 0, 0, (byte)NativeMethods.VideoPowerState.VideoPowerOn, 0, 0, 0, 0 };
      NativeMethods.ExtEscape(hDc, NativeMethods.SETPOWERMANAGEMENT, 12, vpm, 0, IntPtr.Zero);
      NativeMethods.ReleaseDC(IntPtr.Zero, hDc);
    }
  }
}
